import { getToken } from '@/utils/auth'
// import { getRoleList } from "@/api/admin/user.js";
const defaultSettings = require('../../settings.js')

export default (_self) => {
    return {
        editBtn: false,
        delBtn: false,

        index: true,
        indexLabel: '序号',
        align: 'center',
        headerAlign: 'center',
        border: true,
        dialogWidth: '40%',
        stripe: false,
        props: {
            label: 'label',
            value: 'value'
        },
        labelWidth: 120,
        column: [{
                data: {
                    key: getToken()
                },
                tip: '只能上传jpg/png文件，且不超过2m',
                accept: 'image/jpeg,image/png',
                label: '头像',
                prop: 'avatar',
                type: 'upload',
                listType: 'picture-img',
                span: 24,
                slot: true,
                propsHttp: {
                    res: 'datas'
                },
                action: defaultSettings.uploadImg
            },

            {
                label: "登录名",
                prop: "username",

                span: 12,
                // search: true,
                rules: [{
                    required: true,
                    message: "请输入登录名",
                    trigger: "blur"
                }]
            },
            {
                hide: true,
                showColumn: false,
                label: "密码",
                prop: "password",

                row: true,
                span: 12,

                editDisplay: false,
                rules: [{
                    required: true,
                    message: "请输入密码",
                    trigger: "blur"
                }]
            },

            // {
            //     // showColumn: false,
            //     label: "角色名称",
            //     prop: "role_id",
            //     type: 'select',
            //     span: 12,

            //     props: {

            //         label: "role_name",
            //         value: "id",
            //     },
            //     dicUrl: `${
            //         defaultSettings.baseUrl
            //       }/admin/role/get_role_list?key=${getToken()}` +
            //         "&role/get_role_list&limit=2000&page=1",

            //     rules: [{
            //         required: true,
            //         message: "请选择角色",
            //         trigger: "change"
            //     }]
            // },
            {
                hide: true,
                showColumn: false,
                label: "角色名称",
                prop: "role_id",
                type: 'select',
                span: 12,
                props: {
                    res: "datas.data",
                    label: "role_name",
                    value: "id",
                },
                dicFlag: true,
                dicUrl: `${
                    defaultSettings.baseUrl
                  }/admin/role/get_role_list?key=${getToken()}` +
                    "&role/get_role_list&limit=2000&page=1",
                rules: [{
                    required: true,
                    message: "字段分类",
                    trigger: "change"
                }]
            },
            {
                display: false,
                label: "角色名称",
                prop: "role_name",
                span: 12,
            },


            {
                width: 100,
                span: 12,
                label: "是否启用",
                prop: "state",
                // search: true,
                type: 'select',
                slot: true,
                dicData: [{
                        label: '启用',
                        value: 1
                    },
                    {
                        label: '禁用',
                        value: 2
                    }
                ],
                rules: [{
                    required: true,
                    message: '请选择状态',
                    trigger: 'change'
                }],
            },
        ],
    }
}